<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>

	<body>
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
	
			<ul class="breadcrumb">
				<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
				<li>题库管理</li>
				<li class="active">原题库</li>
			</ul>
			<!-- .breadcrumb -->
		</div>
		
		<div class="page-content">
				<div class="page-header">
					<h1>原题库
						<small>
						<i class="icon-double-angle-right"></i>
						查看
						</small>					
					</h1>			
				</div>
				<div>
				<form  id="searchQuesForm" name="searchQuesForm" role="form" method="post" action="${ctx}/sys/question/ques_list">
					<label for="form-field-select-3" style="width:40px;" for="subjectId">科目 </label>
					<select  id="subjectId" name="subjectId" data-placeholder="请选择科目">
						<option value="">请选择科目</option>
						<option value="1" <c:if test="${searchQuesForm.subjectId eq '1'}">selected</c:if> >语文</option>
						<option value="2" <c:if test="${searchQuesForm.subjectId eq '2'}">selected</c:if> >数学</option>
						<option value="3" <c:if test="${searchQuesForm.subjectId eq '3'}">selected</c:if> >英语</option>
					</select>
					
					<label for="form-field-select-3" style="width:40px;margin-left: 20px" for="schoolId">学校 </label>
					<select  id="schoolId" name="schoolId" data-placeholder="请选择学校">
						<option value="">请选择学校</option>
						<option value="1" <c:if test="${searchQuesForm.schoolId eq '1'}">selected</c:if> >上海市建平中学西校</option>
					</select>
					
					<label for="form-field-select-3" style="width:40px;margin-left: 20px" for="classId">年级 </label>
					<select  id="gradeId" name="gradeId" data-placeholder="请选择年级">
						<option value="">请选择年级</option>
						<option value="1" <c:if test="${searchQuesForm.gradeId eq '1'}">selected</c:if> >预初</option>
						<option value="2" <c:if test="${searchQuesForm.gradeId eq '2'}">selected</c:if> >初一</option>
						<option value="3" <c:if test="${searchQuesForm.gradeId eq '3'}">selected</c:if> >初二</option>
						<option value="3" <c:if test="${searchQuesForm.gradeId eq '4'}">selected</c:if> >初三</option>
					</select>
					
					<label for="form-field-select-3" style="width:40px;margin-left: 20px" for="classId">状态 </label>
					<select  id="status" name="status" data-placeholder="请选择状态">
						<option value="">请选择状态</option>
						<option value="1" <c:if test="${searchQuesForm.status eq '1'}">selected</c:if> >未解决</option>
						<option value="2" <c:if test="${searchQuesForm.status eq '2'}">selected</c:if> >已解决</option>
					</select>
					<input id="sysUserInfoSearch" type="submit" value="查询" style="margin-left: 10px"/>
				</form>				
				</div>
				
				<div style="line-height: 10px;">&nbsp;</div>
				
				<div class="row" >
				<div class="col-xs-12">
				<table id="simple-table" class="table table-striped table-bordered table-hover"  style="margin-top:5px;">
							<thead>
								<tr>
									<th class="center" style="width: 30px;">
										<label><input class="ace" type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
									</th>
									<th class='center' style="width:50px;">序号</th>
									<th class="center">所属科目</th>
									<th class="center">学员姓名</th>
									<th class="center">学校</th>
									<th class="center">年级</th>
									<th class="center">班级</th>
									<th class="center">上传时间</th>
									<th class="center" width="120px">原题</th>
									<th class="center">状态</th>
									<th class="center">操作</th>
								</tr>
							</thead>
												
							<tbody id="orderlist">
							<c:forEach var="res" items="${res.data.rows}" varStatus="status">
								<tr  id="ques_info_row_${res.id}" >
									<td class="center">
										<label><input type="checkbox" class="ace" /><span class="lbl"></span></label>
									</td>
									<td class="center" title="${res.id}">&nbsp;${status.index+1}</td>
									<td class="center">
										<c:choose>
					                 		<c:when test="${res.subjectId==1}">语文</c:when>
					                 		<c:when test="${res.subjectId==2}">数学</c:when>
					                 		<c:when test="${res.subjectId==3}">英语</c:when>
					                 	</c:choose>
									</td>
									<td class="center">${res.student.name}</td>
									<td class="center">上海市建平中学西校</td>
									<td class="center">
										<c:choose>
					                 		<c:when test="${res.gradeId==1}">预初</c:when>
					                 		<c:when test="${res.gradeId==2}">初一</c:when>
					                 		<c:when test="${res.gradeId==3}">初二</c:when>
					                 		<c:when test="${res.gradeId==4}">初三</c:when>
					                 	</c:choose>
									</td>
									<td class="center">
										<c:choose>
					                 		<c:when test="${res.classId==1}">1班</c:when>
					                 		<c:when test="${res.classId==2}">2班</c:when>
					                 		<c:when test="${res.classId==3}">3班</c:when>
					                 		<c:when test="${res.classId==4}">4班</c:when>
					                 		<c:when test="${res.classId==5}">5班</c:when>
					                 		<c:when test="${res.classId==6}">6班</c:when>
					                 		<c:when test="${res.classId==7}">7班</c:when>
					                 		<c:when test="${res.classId==8}">8班</c:when>
					                 		<c:when test="${res.classId==9}">9班</c:when>
					                 		<c:when test="${res.classId==10}">10班</c:when>
					                 		<c:when test="${res.classId==11}">11班</c:when>
					                 		<c:when test="${res.classId==12}">12班</c:when>
					                 		<c:when test="${res.classId==13}">13班</c:when>
					                 		<c:when test="${res.classId==14}">14班</c:when>
					                 		<c:when test="${res.classId==15}">15班</c:when>
					                 		<c:when test="${res.classId==16}">16班</c:when>
					                 		<c:when test="${res.classId==17}">17班</c:when>
					                 		<c:when test="${res.classId==18}">18班</c:when>
					                 		<c:when test="${res.classId==19}">19班</c:when>
					                 		<c:when test="${res.classId==20}">20班</c:when>
					                 		<c:when test="${res.classId==21}">21班</c:when>
					                 		<c:when test="${res.classId==21}">22班</c:when>
					                 		<c:when test="${res.classId==23}">23班</c:when>
					                 		<c:when test="${res.classId==24}">24班</c:when>
					                 		<c:when test="${res.classId==25}">25班</c:when>
					                 		<c:when test="${res.classId==26}">26班</c:when>
					                 		<c:when test="${res.classId==27}">27班</c:when>
					                 		<c:when test="${res.classId==28}">28班</c:when>
					                 		<c:when test="${res.classId==29}">29班</c:when>
					                 		<c:when test="${res.classId==30}">30班</c:when>
					                 	</c:choose>
									</td>
									<td class="center">
									 	<fmt:formatDate value="${res.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
									</td>
									
									<td  class="center">
										<a  href="${ctx}/../upload/${res.url}" data-rel="colorbox">
												<img src="${ctx}/../upload/${res.url}" style="width: auto;height: 80px;"/>
										</a>
									</td>
									<td  class="center" id="question_status_${res.id}">
										<c:choose>
					                 		<c:when test="${res.status==1}">未解决</c:when>
					                 		<c:when test="${res.status==2}">已解决</c:when>
					                 	</c:choose>
									</td>
									<td class="center">
										<button class="btn btn-xs btn-info" onclick="location='${ctx}/sys/question/toUpdate/${res.id}'">
											<i class="icon-edit bigger-120"></i>
										</button>
										
										<button class="btn btn-xs btn-danger" onclick="javascript:deleteQuestion(${res.id});">
											<i class="icon-trash bigger-120"></i>
										</button>
										<button class="btn btn-xs btn-info" onclick="javascript:resloveQuestion(${res.id});">
											<i class="icon-comment bigger-120"></i>
										</button>
									</td>
								</tr>
							</c:forEach>
							
							
							</tbody>
				</table>
				<%@ include file="/WEB-INF/views/decorators/page.jsp"%> 
				</div>
				</div>
			</div>
			<script type="text/javascript">
			jQuery(function($) {
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			})
			
			function deleteQuestion(orderId){
				if(confirm("您确认删除该条记录吗?")){
					//resetRowById(userId);
					$.ajax({
						type : "DELETE",
						dataType: "json",
						async: false,
						url: '${ctx}/sys/question/delete/'+orderId,
						success: function (data) {
									if(data!=undefined&&data.status!=undefined&&data.status.trim()=="0"){
										$("#ques_info_row_"+orderId).remove();
										alert("删除成功。");
									}else{
										alert("error:"+data.error);
									}
								 },
						error: function(data) {
									alert("删除失败。");
								}
					});
					return false;
				}
			}
			
			function resloveQuestion(questionId){
				if(confirm("您确认改问题被解决吗?")){
					//resetRowById(userId);
					$.ajax({
						type : "POST",
						dataType: "json",
						async: false,
						url: '${ctx}/sys/question/reslove/'+questionId,
						success: function (data) {
									if(data!=undefined&&data.status!=undefined&&data.status.trim()=="0"){
										jQuery('#question_status_'+questionId).html("已解决");
										alert("更新成功。");
									}else{
										alert("error:"+data.error);
									}
								 },
						error: function(data) {
									alert("更新失败。");
								}
					});
					return false;
				}
			}
			
			jQuery(function($) {
				var colorbox_params = {
					reposition:true,
					scalePhotos:true,
					scrolling:false,
					previous:'<i class="icon-arrow-left"></i>',
					next:'<i class="icon-arrow-right"></i>',
					close:'&times;',
					current:'{current} of {total}',
					maxWidth:'100%',
					maxHeight:'100%',
					onOpen:function(){
						document.body.style.overflow = 'hidden';
					},
					onClosed:function(){
						document.body.style.overflow = 'auto';
					},
					onComplete:function(){
						$.colorbox.resize();
					}
				};

				$('[data-rel="colorbox"]').colorbox(colorbox_params);
				$("#cboxLoadingGraphic").append("<i class='icon-spinner orange'></i>");//let's add a custom loading icon
			})
			</script>
	</body>

</html>
